package vn.bk.hotel;

import java.util.ArrayList;

import vn.bk.hotel.adapter.DatabaseHotel;
import vn.bk.hotel.adapter.ListHotelAdapter;
import vn.bk.hotel.object.HotelInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockFragment;

public class FavoriteHotel extends SherlockFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
	    Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	View v = inflater.inflate(R.layout.favorite, container, false);
	ListView list = (ListView) v.findViewById(R.id.list_favorite);
	TextView text = (TextView) v.findViewById(R.id.tv_not_fav);
	DatabaseHotel mDB = new DatabaseHotel(getActivity());
	ArrayList<HotelInfo> allHotel = mDB.getAllHotels();
	ViewMap.isDirection = false;
	if (allHotel != null) {
	    if (allHotel.size() != 0) {
		ListHotelAdapter adapter = new ListHotelAdapter(getActivity(),
			allHotel);
		list.setAdapter(adapter);
		text.setVisibility(TextView.INVISIBLE);
	    } else {
		list.setVisibility(ListView.INVISIBLE);
		text.setText(getString(R.string.null_favorite));
	    }
	} else {
	    list.setVisibility(ListView.INVISIBLE);
	    text.setText(getString(R.string.null_favorite));
	}
	return v;
    }

}
